<?php
namespace Home\Controller;
use Think\Controller;
class ProcessController extends Controller {
    public function _initialize()
    {
        //自动加载的类
        new \Org\Autoload();

        $this->member_id = $this->member_info['member_id'];
        //echo $member_id;exit;
    }
    //首页
    public function index($page=1,$sort=''){
        if(session('member_id')){
            $member_id=session('member_id');
            $member_name=session('member_name');
        }
        $data['title']='找加工 找金银网';
        $data['active']='process';
//        $Model=D("Process");
//        $base_url='/home/process/index';
//        //参数  页数
//        if(intval($page)==0){
//            $page=1;
//        }else{
//            $page=intval($page);
//        }
//        //排序
//        if($sort!=''){
//            $sort=addslashes($sort);
//            if($sort=='price-asc'){
//                $process_sort='process_price asc';
//                $base_url.='/sort/'.$sort;
//            }
//            if($sort=='price-desc'){
//                $process_sort='process_price desc';
//                $base_url.='/sort/'.$sort;
//            }
//            if($sort=='time-asc'){
//                $process_sort='process_time asc';
//                $base_url.='/sort/'.$sort;
//            }
//            if($sort=='time-desc'){
//                $process_sort='process_time desc';
//                $base_url.='/sort/'.$sort;
//            }
//            $Model->process_sort=$process_sort;
//        }
//        $perpage=10;
//        $Model->page=$page;
//        $Model->perpage=$perpage;
//        //echo $member_id;exit;
//        $Model->member_id=$member_id;
//        $process_list=$Model->get_process_list();
//        //print_r($supply_list);exit;
//        $process_total=$Model->get_process_total();
//        //echo $supply_total;exit;
//        $page_total=ceil($process_total/$perpage);
//        //echo $page_total;exit;
//        //分页数据
//        if($page!=1&&$page_total>1){
//            $last_page=$page-1;
//        }else{
//            $last_page=1;
//        }
//        if($page_total>$page){
//            $next_page=$page+1;
//        }else{
//            $next_page=$page;
//        }
//        $pager['current_page']=$page;
//        $pager['perpage']=$perpage;
//        $pager['last_page']=$last_page;
//        $pager['next_page']=$next_page;
//        $pager['process_total']=$process_total;
//        $pager['page_total']=$page_total;
//        //$cat_list=$Model->get_cat_list();
//        $this->assign("process_list", $process_list);
//        //$this->assign("cat_list", $cat_list);
//        $this->assign("pager",$pager);
//        $this->assign("base_url",$base_url);
////        $this->assign("sort_info",$sort_info);
//        $this->assign("member_id", $member_id);
//        $this->assign("member_name", $member_name);
        $this->assign("data", $data);
        $this->display();
    }
    //获取AJAX数据
    public function get_ajax_data(){
        if(session('member_id')==''){
            $data['msg']='没有登录';
        }else{
            $process_id=I('post.process_id');
            $data=array();
            $data['msg']='ok';
            $Model=D("Process");
            $Model->process_id=$process_id;
            $data['info']=$Model->get_ajax_info();
        }
        echo json_encode($data);
    }
    //提交AJAX数据
    public function submit_ajax_data(){
        if(session('member_id')==''){
            $data['msg']='没有登录';
        }else {
            $member_id = I('post.member_id');
            $process_id = I('post.process_id');
            $message_content = I('post.message_content');
            $process_time = time();

            $data = array();
            $post['process_id'] = $process_id;
            $post['member_id'] = $member_id;
            $post['message_content'] = $message_content;
            $post['message_time'] = $process_time;

            //写入加工留言表
            $Model = D("ProcessMessage");
            $Model->post = $post;
            if (!$Model->message_add_post()) {
                $data['msg'] = '写入数据库失败,请您重新提交';
                exit;
            }
            $data['msg']='ok';
//            $data=$member_id;
        }
        echo json_encode($data);
    }
            //print_r($post);exit;
    /*//报价
    public function reg(){
        $data['title']='注册 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //登录
    public function login(){
        $data['title']='登录 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function center(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function dantiao(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function baojiadan(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function wodecaigou(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function wodegonghuo(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function xiugai(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }
    //会员中心
    public function zengxin(){
        $data['title']='会员中心 找金银网';
        $this->assign("data", $data);
        $this->display();
    }*/
}